<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass="App\Repository\MessageRepository")
 */
class Message
{
    /**
     * @Groups({"app"})
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @Groups({"app"})
     * @ORM\Column(type="string", length=255)
     */
    private $title;

    /**
     * @Groups({"app"})
     * @ORM\Column(type="text")
     */
    private $content;

    /**
     * @Groups({"app"})
     * @ORM\Column(type="datetime")
     */
    private $createAt;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $toid;

    /**
     * @Groups({"cat"})
     * @ORM\ManyToOne(targetEntity="App\Entity\MessageCategory", inversedBy="messages")
     * @ORM\JoinColumn(nullable=false)
     */
    private $cat;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getTitle(): ?string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function getContent(): ?string
    {
        return $this->content;
    }

    public function setContent(string $content): self
    {
        $this->content = $content;

        return $this;
    }

    public function getCreateAt(): ?\DateTimeInterface
    {
        return $this->createAt;
    }

    public function setCreateAt(\DateTimeInterface $createAt): self
    {
        $this->createAt = $createAt;

        return $this;
    }

    public function getToid(): ?int
    {
        return $this->toid;
    }

    public function setToid(?int $toid): self
    {
        $this->toid = $toid;

        return $this;
    }

    public function getCat(): ?MessageCategory
    {
        return $this->cat;
    }

    public function setCat(?MessageCategory $cat): self
    {
        $this->cat = $cat;

        return $this;
    }
}
